package com.srcptit.trainning.toannt.btvn3;

public class bai_8 {
	 //kiem tra thoa man so nguyen to
	 static boolean testngto(int n){
		 	if(n==0||n==1||n==2)return true;
		 	 for(int i=2;i<=Math.sqrt(n);i++){
		 		 if(n%i==0)
		 			 return false;
		 	 }
		 	 return true;
	 }
	 //kiem tra thoa man de bai
	 static boolean test(int n){
		 int t=n,k1=0,k2=0;
		 while(n!=0){
			 k1=n%10;
			 if(testngto(k1)==false||k2>k1)return false;
			 k2=k1;
			 n=n/10;
		 }
		 if(testngto(t))return true;
		 return false;
		 
	 }
	 //chuong trinh chinh
	 public static void main(String[]args){
		 int dem=0;
		 System.out.println("Ket qua cua chuong trinh:");
		 for(int i=1000000;i<=9999999;i++){
			 if(test(i)){
				 System.out.println(i);
			 dem++;}
		 }
		 System.out.println("Co "+dem+" so thoa man.");
	 }
}
